/*
 * Copyright 2011-2012 by The Regents of the University of California Licensed
 * under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. you may obtain a copy of the
 * License from
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package edu.ucsd.db.bassarisk.schema;

import java.util.ArrayList;
import java.util.List;

import edu.ucsd.db.bassarisk.schema.Schema.Cardinality;
import edu.ucsd.db.bassarisk.schema.visitor.SchemaNodeVisitor;

public class DisjointChildrenNode extends SchemaNode implements InternalSchemaNode {
  private final List<SchemaNode> children;

  protected DisjointChildrenNode() {
    super("", Cardinality.Meta);
    this.children = new ArrayList<SchemaNode>();
  }

  @Override
  public <R, A> R accept(final SchemaNodeVisitor<R, A> visitor, final A arg) {
    return visitor.visitDisjointChildrenNode(this, arg);
  }

  @Override
  public void addChild(final SchemaNode newChild) {
    this.children.add(newChild);
  }

  @Override
  public List<SchemaNode> getChildren() {
    return this.children;
  }

  @Override
  public String toString() {
    return String.format("disjointSchema(%s)", this.children.size());
  }
}
